package com.tanhua.manager;

import com.tanhua.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.Map;

@RestController
@RequestMapping(value = "/manage")
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping(value ="/users",name = "用户列表分页查询")
    public ResponseEntity findUserAllPage(@RequestParam(defaultValue = "1") Integer page,
                                       @RequestParam(defaultValue = "10") Integer pagesize) throws IOException {
        //调用service生成验证码
        return userService.findUserAllPage(page,pagesize);
    }

    @GetMapping(value ="/users/{userID}",name = "根据用户id查看该用户详情")
    public ResponseEntity findUserById(@PathVariable("userID") Long userId) throws IOException {
        //根据用户id查看该用户详情
        return userService.findUserById(userId);
    }

    @GetMapping(value ="/videos",name = "根据用户id查看该用户小视频")
    public ResponseEntity findUserVideo(@RequestParam(defaultValue = "1") Integer page,
                                       @RequestParam(defaultValue = "10") Integer pagesize,
                                       Long uid) throws IOException {
        //根据用户id分页查看该用户小视频
        return userService.findUserVideo(page,pagesize,uid);
    }

    @GetMapping(value ="/messages",name = "根据用户id查看该用户发布过的圈子动态")
    public ResponseEntity findQuanZi(@RequestParam(defaultValue = "1") Integer page,
                                        @RequestParam(defaultValue = "10") Integer pagesize,
                                        Long uid,Integer state) throws IOException {
        //根据用户id分页查看该用户小视频
        return userService.findQuanZi(page,pagesize,uid,state);
    }


    @GetMapping(value ="/messages/{id}",name = "根据用户id查看该用户指定的圈子动态")
    public ResponseEntity findQuanZiById(@PathVariable("id") String publishId) throws IOException {
        //根据用户id查看该用户指定的圈子动态
        return userService.findQuanZiById(publishId);
    }


    @GetMapping(value ="/messages/comments",name = "根据用户id查看该用户指定的圈子动态评论")
    public ResponseEntity findQuanZiComment(@RequestParam(defaultValue = "1") Integer page,
                                         @RequestParam(defaultValue = "10") Integer pagesize,
                                        String messageID) throws IOException {
        //根据用户id查看该用户指定的圈子动态
        return userService.findQuanZiComment(page,pagesize,messageID);
    }

    @PostMapping(value="/messages/pass",name = "复审通过")
    public ResponseEntity commentAuditTrue(@RequestBody String[] param){
        System.out.println(param.length);
        return userService.commentAuditTrue(param);
    }

    @PostMapping(value="/messages/reject",name = "复审不通过")
    public ResponseEntity commentAuditFalse(@RequestBody String[] param){
        System.out.println(param.length);
        return userService.commentAuditFalse(param);
    }








}
